<template>
  <div style="text-align: center;">
    <el-form label-width="125px" style="max-width: 460px;margin: 0 auto auto;">
      <el-form-item label="名">
        <el-input v-model="author.firstName" placeholder="请输入作者名字"/>
      </el-form-item>
      <el-form-item label="姓">
        <el-input v-model="author.lastName" placeholder="请输入作者姓氏"/>
      </el-form-item>
      <el-form-item label="ORCID">
        <el-input v-model="author.orcid" placeholder="请输入作者ORCID"/>
      </el-form-item>
      <el-form-item label="所在地区（国家）">
        <el-input v-model="author.region" placeholder="请输入作者所在地区（国家）"/>
      </el-form-item>
      <el-form-item label="所在城市">
        <el-input v-model="author.city" placeholder="请输入作者所在城市"/>
      </el-form-item>
      <el-form-item label="工作单位">
        <el-input v-model="author.workStation" placeholder="请输入作者工作单位"/>
      </el-form-item>
      <el-form-item label="邮箱">
        <el-input v-model="author.email" placeholder="请输入作者邮箱"/>
      </el-form-item>
      <el-form-item label="领域">
        <el-input v-model="dns" placeholder="请输入作者领域，多个领域使用 ; 分割" @input="checkDomainsInput"/>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import {defineModel, inject} from "vue";

const author = defineModel()
const dns = inject('dns')

const checkDomainsInput = () => {
  if (dns.value) {
    dns.value = dns.value.replace('；', ';')
    dns.value = dns.value.replace(/[^\u4e00-\u9fa5；;a-zA-Z0-9]/g, '') // 移除非中文字符和中英文分号
    dns.value = dns.value.replace(';;', ';')
    if (dns.value[0] === ';') {
      dns.value = dns.value.substring(1)
    }
  }
}
</script>


<style scoped>

</style>